<?php
$communityApiPath	= dirname ( __FILE__ ).'/CommunityApi/';
require_once $communityApiPath.'QQCommunity.php';
require_once $communityApiPath.'QQWBCommunity.php';
require_once $communityApiPath.'SinaWBCommunity.php';
require_once $communityApiPath.'BaiduCommunity.php';
require_once $communityApiPath.'TaobaoCommunity.php';
/**
 * 实现工厂类
 */
class CommunityFactory{
	public static function init($type)
	{
		switch (strtolower($type))
		{
			case 'qq':
				$obj	= new QQCommunity();
				break;
			case 'qqwb':
				$obj	= new QQWBCommunity();
				break;
			case 'sinawb':
				$obj	= new SinaWBCommunity();
				break;
			case 'baidu':
				$obj	= new BaiduCommunity();
				break;
			case 'taobao':
				$obj	= new TaobaoCommunity();
				break;
			default:
				throw new CHttpException ( 404, '系统错误,请重试！' );
		}
		
		if ($obj instanceof ICommunity){
			return $obj;
		}else{
			throw new CHttpException ( 404, '系统错误,请重试！' );
		}
	}
}